import java.util.*;
public class Person{
    private Certificate code;
    private String name;
    private int cash;
    private List<Car> cars = new ArrayList<Car>();

    public Person(){
    }

    public Person(Certificate  code, String name, int cash){
        this.code = code;
        this.name = name;
        this.cash = cash;
    }

    private boolean buyCar(Car car){
        return true;
    }

    public boolean buyCar(Car car, Person p){
        car.setOwner(p);
        this.addCar(car);
        this.setCash(this.cash - car.getCost());

        return true;
    }

    public void sellCar(Car car){
        this.setCash(this.cash + car.getCost());
        this.removeCar(car);
        
    }

    public void addCar(Car car){
        this.cars.add(car);
    }

    public void removeCar(Car car){
        this.cars.remove(car);
    } 

    public boolean hasCar(Car car){
        
        return this.cars.contains(car);
    }

    public String toString(){
        return this.name;
    }


    public Certificate getCode(){
        return this.code;
    }

    public void setCode(Certificate code){

    }

    public String getName(){
        return this.name;
    }

    public void setName(String name){

    }

    public int getCash(){
        return this.cash;
    }

    public void setCash(int cash){
        this.cash = cash;
    }

    public List<Car> getCars(){
        return this.cars;
    }

}
